 function addSignature() {
	 var signature = $("#autocompleteSignaturePanelConfig").val();
	 var startDay = $("#panelConfigSignatureStartDay").val();
	 var endDay = $("#panelConfigSignatureEndDay").val();
	 var period={"description":signature,"type":"3","startDate":startDay,"endDate":endDay};
	 if(signature==""||startDay==""||endDay==""){
		 //alert("Faltan datos para agregar el periodo.");
		 $("#dialogPeriod1").dialog();
	 }else{
		  
		 if(!equalPeriodOrOverlap(period)){
			 insertSpecialPeriodToSubject(signature,period);
			 //$("#addSignaturePanel").append("<div class='addSignatureSpecialPeriod'>" + signature + "</div><div class='addSignatureSpecialPeriod'>" + startDay + "</div><div class='addSignatureSpecialPeriod'>" + endDay + "</div>");
		 }else{
			 //alert("El periodo especial ya existe o para la misma materia hay fechas que se superponen.");
			 $("#dialogPeriod2").dialog();
		 }
		 $("#autocompleteSignaturePanelConfig").val("");
		 $("#panelConfigSignatureStartDay").val("");
		 $("#panelConfigSignatureEndDay").val("");
	 
	 }
 }
 
 function generateTableSpecialPeriod(listSpecialPeriod) {
	 var currentDiv = $("#addSignaturePanel");
		var table;
		var tr = '';
		currentDiv.html('');
		
		if(!getSchedulerNotEditable()){
			table="<table class='table table-hover'><thead><tr><th>Materia</th><th>Fecha Inicio</th><th>Fecha Fin</th><th></th></tr></thead><tbody>";
		}else{
			table="<table class='table table-hover'><thead><tr><th>Materia</th><th>Fecha Inicio</th><th>Fecha Fin</th></tr></thead><tbody>";
		}
				
		for(var i = 0; i<listSpecialPeriod.length; i++){
			var auxDiv = listSpecialPeriod[i];
			var signature = auxDiv["description"];
			var startDay = auxDiv["startDate"];
			var endDay = auxDiv["endDate"];
			var semiCol=";";
			var button="";
			if(!getSchedulerNotEditable()){
				button="<td><button onclick='deleteSpecialPeriod("+'"'+signature+semiCol+startDay+semiCol+endDay+'"'+");'>Eliminar</td>";
			}
			tr += "<tr><td>"+signature+"</td><td>"+startDay+"</td><td>"+endDay+"</td>"+button+"</tr>";
		}
		table += tr + "</tbody></table>";
		currentDiv.append(table);
 }
 
 function deleteSpecialPeriod(strPeriod){
	 //servicio para borrar
	 var arrPeriod=strPeriod.split(";");
	 var period={"description":arrPeriod[0],"type":"3","startDate":arrPeriod[1],"endDate":arrPeriod[2]};
	 var periodDTO={"period":period,"plannId":getCurrentPlannId()};
	 postJSON("/enma/planning/deleteSpecialPeriod/",periodDTO, function(data) {
			if(data){
				if(subjectSpecialPeriods[arrPeriod[0]]){
					for(var idx in subjectSpecialPeriods[arrPeriod[0]]){
						var pTComp=subjectSpecialPeriods[arrPeriod[0]][idx];
						if(arrPeriod[1]==pTComp["startDate"]&&arrPeriod[2]==pTComp["endDate"]){
							delete subjectSpecialPeriods[arrPeriod[0]][idx];
							fillSpecialPeriodTable();
						}
					}
				}
				
			}else{
				//alert("Hubo un error al eliminar periodo espacial.");
				$("#dialogPeriod3").dialog();
			}

		});
	 
	 
 }